import React from "react"
import {
  BrowserRouter as Router,
  Route,
  Switch,
  Redirect,
} from "react-router-dom"
import Login from "./component/Login"
import Course from "./component/Course"
import Register from "./component/Register"

export default function App(props) {
  let [studentId, setStudentId] = React.useState(-1)

  return (
    <div>
      <h1>App.jsx</h1>
      hello world
      <Router>
        <Switch>
          <Route path="/login">
            <Login loginUrl={props.urls.loginUrl} setStudentId={setStudentId} />
          </Route>
          <Route path="/register">
            <Register registerUrl={props.urls.registerUrl} />
          </Route>
          <Route path="/course">
            <Course courseUrl={props.urls.courseUrl} studentId={studentId} />
          </Route>
          <Redirect from="/" to="/login" />
        </Switch>
      </Router>
    </div>
  )
}
